/**
 * Created by zhubuqing on 2018/5/5.
 */
var schoolId = 0;
var nowSchoolName = "";
var theSchoolType = 0;
var myUsername = "";

$(function () {
    commonAjax(baseUrl + "/login/getTeacherType", "", "getTeacherTypeRes", "POST");
    commonAjax(baseUrl + "/login/getTeacherNameAndPic", "", "getTeacherNameAndPicRes", "POST");
    commonAjax(baseUrl + "/login/isFamours", "", "isFamoursRes", "POST");
    commonAjax(baseUrl + "/login/getTeacherSchoolId", "", "getTeacherSchoolIdRes", "POST");
    commonAjax(baseUrl + "/login/getTeacherName", "", "getTeacherNameRes", "POST");
})

function getTeacherTypeRes(res) {
    var resultData = res.obj;

    if (resultData == "TEACHER" || resultData == "INSTRUCTOR") {
        $("#gxxxgl_main").hide();
        $("#xinXiGuanLi").hide();
    } else if (resultData == "OTHER") {
        $("#my_mes").hide();
        $("#xinXiGuanLi").hide();
    }
}

function getTeacherNameAndPicRes(res) {
    if (pageName()[0] == "my_mes") {
        myUsername = res.obj[0];
        getMyInfo();
    } else if (pageName()[0] == "ms_inside") {
        myUsername = res.obj[0];
        getMyInfo();
    }
}

function getTeacherNameRes(res) {
    $("#teacherUsername").html(res.obj + "老师");
}

function isFamoursRes(res) {
    if (res.obj == "false") {
        $("#mingShiGongZuoShiGuanLi").hide();
    }
}

function getTeacherSchoolIdRes(res) {
    var school = res.obj;
    schoolId = school.id;
    nowSchoolName = school.schoolName;
    if (school.type == "UNDER_GRADUATE") {
        theSchoolType = 1;
    } else {
        $("#zheJiangProvinceUniversityMoralEducationTextbookUseAll").hide();
        $("#xueKeJianSheQingKuang").hide();
    }
    $("#schoolHeadPic").attr("src", school.pic);
    if (pageName()[0] == "xxgl") {
        xxglInit();
    }
}

function pageName() {
    var a = location.href;
    var b = a.split("/");
    var c = b.slice(b.length - 1, b.length).toString(String).split(".");
    return c.slice(0, 1);
}